/**
 * <copyright>
 * </copyright>
 *
 */
package de.sabram.upb.specs.lido.impl;

import de.sabram.upb.specs.lido.ChainName;
import de.sabram.upb.specs.lido.ChainNames;
import de.sabram.upb.specs.lido.LidoPackage;
import de.sabram.upb.specs.lido.TypeId;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Chain Names</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.sabram.upb.specs.lido.impl.ChainNamesImpl#getTypeId <em>Type Id</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.ChainNamesImpl#getChainNames <em>Chain Names</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ChainNamesImpl extends ChainSpecImpl implements ChainNames
{
  /**
   * The cached value of the '{@link #getTypeId() <em>Type Id</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTypeId()
   * @generated
   * @ordered
   */
  protected TypeId typeId;

  /**
   * The cached value of the '{@link #getChainNames() <em>Chain Names</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getChainNames()
   * @generated
   * @ordered
   */
  protected EList<ChainName> chainNames;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ChainNamesImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return LidoPackage.Literals.CHAIN_NAMES;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public TypeId getTypeId()
  {
    return typeId;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetTypeId(TypeId newTypeId, NotificationChain msgs)
  {
    TypeId oldTypeId = typeId;
    typeId = newTypeId;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.CHAIN_NAMES__TYPE_ID, oldTypeId, newTypeId);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTypeId(TypeId newTypeId)
  {
    if (newTypeId != typeId)
    {
      NotificationChain msgs = null;
      if (typeId != null)
        msgs = ((InternalEObject)typeId).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.CHAIN_NAMES__TYPE_ID, null, msgs);
      if (newTypeId != null)
        msgs = ((InternalEObject)newTypeId).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.CHAIN_NAMES__TYPE_ID, null, msgs);
      msgs = basicSetTypeId(newTypeId, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.CHAIN_NAMES__TYPE_ID, newTypeId, newTypeId));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<ChainName> getChainNames()
  {
    if (chainNames == null)
    {
      chainNames = new EObjectContainmentEList<ChainName>(ChainName.class, this, LidoPackage.CHAIN_NAMES__CHAIN_NAMES);
    }
    return chainNames;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case LidoPackage.CHAIN_NAMES__TYPE_ID:
        return basicSetTypeId(null, msgs);
      case LidoPackage.CHAIN_NAMES__CHAIN_NAMES:
        return ((InternalEList<?>)getChainNames()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case LidoPackage.CHAIN_NAMES__TYPE_ID:
        return getTypeId();
      case LidoPackage.CHAIN_NAMES__CHAIN_NAMES:
        return getChainNames();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case LidoPackage.CHAIN_NAMES__TYPE_ID:
        setTypeId((TypeId)newValue);
        return;
      case LidoPackage.CHAIN_NAMES__CHAIN_NAMES:
        getChainNames().clear();
        getChainNames().addAll((Collection<? extends ChainName>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case LidoPackage.CHAIN_NAMES__TYPE_ID:
        setTypeId((TypeId)null);
        return;
      case LidoPackage.CHAIN_NAMES__CHAIN_NAMES:
        getChainNames().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case LidoPackage.CHAIN_NAMES__TYPE_ID:
        return typeId != null;
      case LidoPackage.CHAIN_NAMES__CHAIN_NAMES:
        return chainNames != null && !chainNames.isEmpty();
    }
    return super.eIsSet(featureID);
  }

} //ChainNamesImpl
